package adapter;

import java.util.ArrayList;

import com.adgroup.doremon_ad.R;
import com.adgroup.doremon_ad.Menufragment;


import model.MyApp;
import model.VideoID;


import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AdapterMyApp extends BaseAdapter {
	private Context context;
	private ArrayList<MyApp> myApps;

	public AdapterMyApp(Context context, ArrayList<MyApp> myApps) {
		this.context = context;
		this.myApps = myApps;		
	}

	@Override
	public int getCount() {
		return myApps.size();
	}

	@Override
	public Object getItem(int arg0) {
		return myApps.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		Holder holder;
		LayoutInflater inflater = ((Activity) context).getLayoutInflater();
		if (arg1 == null) {
			holder = new Holder();
			arg1 = inflater.inflate(R.layout.item_myapp, null); 
			holder.tv = (TextView) arg1
					.findViewById(R.id.textViewMyApp);
			holder.iv = (ImageView) arg1
					.findViewById(R.id.imageView1);
			arg1.setTag(holder);
		} else {
			holder = (Holder) arg1.getTag();
		} 
		/*MyApp myapp = myApps.get(arg0);
		if(arg0<4){
			holder.tv.setText(myapp.getName());
			holder.iv.setImageResource(Integer.parseInt(myapp.getLink()));
		}
		else if(arg0==0){
			
		}
		else*/{
			holder.tv.setText(myApps.get(arg0).getName());
		}
		
		return arg1;
	}
	public class Holder {
		TextView tv;
		ImageView iv;
	}
}
